package demo.model.bean;



import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.NotEmpty;


/**
 * @author   zkessentials store  This class provides a representation of a   {@code   User}  
 */
@Entity
@Table(name="users")
public class User {

	/**
	 * @uml.property  name="id"
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private long id;

	@Column(name="firstname")
	private String firstName;

	@Column(name="lastname")
	private String lastName;

	@Column(name="login")
	private String login;

	@Column(name="mail")
	private String mail;
	
	@Column(name="password")
	private String password;

	/**
	 * @uml.property  name="role"
	 */
	@Column(name="userrole")
	private String role;

	@Email(message = "Must be a valid email")
	public String getMail() {
		return this.mail;
	}

	public void setMail(String mail) {
		this.mail = mail;
	}

	@NotEmpty(message = "Login can not be null")
	public String getLogin() {
		return this.login;
	}

	public void setLogin(String login) {
		this.login = login;
	}

	@NotEmpty(message = "First name can not be null")
	public String getFirstName() {
		return this.firstName;
	}

	public void setFirstName(String firstname) {
		this.firstName = firstname;
	}

	@NotEmpty(message = "Last name can not be null")
	public String getLastName() {
		return this.lastName;
	}

	public void setLastName(String lastname) {
		this.lastName = lastname;
	}

	/**
	 * @return
	 * @uml.property  name="id"
	 */
	public long getId() {
		return this.id;
	}

	/**
	 * @param  id
	 * @uml.property  name="id"
	 */
	public void setId(long id) {
		this.id = id;
	}
	
	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	/**
	 * @return
	 * @uml.property  name="role"
	 */
	public String getRole() {
		return role;
	}

	/**
	 * @param  role
	 * @uml.property  name="role"
	 */
	public void setRole(String role) {
		this.role = role;
	}

	public User(long id, String firstname, String lastname, String login, String mail, String password, String role) {
		super();
		this.id = id;
		this.firstName = firstname;
		this.lastName = lastname;
		this.login = login;
		this.mail = mail;
		this.password = password;
		this.role = role;
	}

	public User() {

	}

	// mock data source //
	/**
	 * @uml.property  name="_user"
	 * @uml.associationEnd  
	 */
	private static final User _user;
	static {
		_user = new User(1, "John", "Shepard", "zk", "truc@bidule.com", "zk", "admin");
	}

	/**
	 * @return
	 * @uml.property  name="_user"
	 */
	public static User getUser() {
		return _user;
	}

	// query //
	public String getFullDesc() {
		return this.firstName + " " + this.lastName + " " + this.login + " " + this.role + " ";
	}
}
